package  
{
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import iks.game.*;
	import iks.utils.ui.*;
	
	public final class VerletStickTest extends Sprite 
	{
		
		public function VerletStickTest() 
		{
			KGame.getInstance().init(this.stage, initFunction, logicFunction, 60);
			KGame.getInstance().start();
		}
		
		private function initFunction() : void
		{
			m_stageRect = new Rectangle(0, 0, 640, 480);
			m_pointA = new VerletPoint(100, 100);
			m_pointB = new VerletPoint(105, 200);
			m_stick = new VerletStick(m_pointA, m_pointB);
		}
		
		private function logicFunction() : void
		{
			if (KInput.isKeyPress(KKeyboard.SPACE))
			{
				m_pointA.y += 0.5;
				m_pointA.update();
				
				m_pointB.y += 0.5;
				m_pointB.update();
				
				for (var i : int = 0; i < 1; ++i)
				{
					m_pointA.constrain(m_stageRect);
					m_pointB.constrain(m_stageRect);
					m_stick.update();
				}
				
				this.graphics.clear();
				this.graphics.beginFill(0xA0A0A0);
				this.graphics.drawRect(m_stageRect.x, m_stageRect.y, m_stageRect.width, m_stageRect.height);
				this.graphics.endFill();
				m_pointA.render(this.graphics);
				m_pointB.render(this.graphics);
				m_stick.render(this.graphics);
			}
		}
		
		private var m_stick : VerletStick = null;
		private var m_pointA : VerletPoint = null;
		private var m_pointB : VerletPoint = null;
		private var m_stageRect : Rectangle = null;
	}

}


































///////////////////////////////////////////////////////////////////////////////////////////////////
// end file


